<fieldset id="fd1" style="width:95%;margin:5px;">
	<legend><span>工单信息查询</span></legend>
	<div class="fieldset-body">
		<table class="form-table" border="0" cellpadding="1" cellspacing="2">
			<tr>
				<td class="form-label" style="width:100px;">施工组织机构:</td>
				<td style="width:150px"><input id="conagency" expandOnLoad="true" class="mini-treeselect" url="/common/agencyOne" multiSelect="false" textField="name" valueField="id" parentField="parent" checkRecursive="true" showFolderCheckBox="true" style="width:100%;"/></td>
				<td class="form-label" style="width:80px;">工单类型:</td>
				<td style="width:100px"><input id="types" class="mini-combobox" textField="name" valueField="id" data="JS.CONST[5]" allowInput="true" style="width:100%;" /></td>
				<td class="form-label" style="width:80px;">工单编号:</td>
				<td style="width:100px"><input id="order_no" class="mini-textbox" emptyText="请输入工单编号" style="width:100%;"/></td>
				<td class="form-label" style="width:80px;">售后单编号:</td>
				<td style="width:100px"><input id="order_id" class="mini-textbox" emptyText="请输入售后单编号" style="width:100%;"/></td>
				<td style="width:80px;"><a class="mini-button" id="search" iconCls="icon-search">查询...</a></td>
			</tr>
		</table>
	</div>
</fieldset>
<div class="mini-toolbar" style="padding:0px;margin:6px 0px 0px 0px;border-bottom:0;width:100%;">
	<table style="width:100%;">
		<tr>
			<td style="width:100%;">
				<a class="mini-button" iconCls="icon-search" id="buttonEnd" onClick="BusinessInfo('id')" plain="true">查看工单详情</a>
				<a class="mini-button" iconCls="icon-search" id="buttonStart1" onClick="CustomerInfo('customer_id')" plain="true">查看顾客详情</a>
				<span class="separator"></span>
				<a class="mini-button" iconCls="icon-download" id="buttonGet" onclick="BusinessGet()" plain="true">领取设备</a>
				<span class="separator"></span>
				<a class="mini-button" iconCls="icon-upload" id="buttonSet" onclick="BusinessSet()" plain="true">归还设备</a>
				<span class="separator"></span>
			</td>
		</tr>
	</table>
</div>
<table style="width:100%;height:75%;">
	<tr>
		<td style="width:100%;height:100%;">
			<div id="grid1" class="mini-datagrid" allowAlternating="true" idField="id" pageSize="20" onselectionchanged="onSelectionChanged" style="width:100%;height:100%;" url="/business/conDispatchingList" >
				<div property="columns">
					<div type="checkcolumn" headerAlign="center">选择</div>
					<div field="id" width="60" headerAlign="center" allowSort="true">工单编号</div>
					<div field="typename" width="60" headerAlign="center" allowSort="true" align="center">工单类型</div>
					<div field="title" width="80" headerAlign="center">标题</div>
					<div field="content" width="120" headerAlign="center">工单内容</div>
					<div field="remark" width="180" headerAlign="center">备注<input property="editor" class="mini-textarea" emptyText="请输入备注" style="width:100%;height:40px;"/></div>
					<div field="statusname" width="80" headerAlign="center" Align="center" allowSort="true">状态</div>
				</div>
			</div>
		</td>
		<td style="width:450px;height:100%;">
			<div id="grid2" class="mini-datagrid" allowAlternating="true" idField="id" pageSize="20" style="width:450px;height:100%;" url="/business/businessDevice" >
				<div property="columns">
					<div type="indexcolumn" headerAlign="center">编号</div>
					<div field="did" width="60" headerAlign="center" allowSort="true">设备编号</div>
					<div field="staff" width="60" headerAlign="center" allowSort="true">员工</div>
					<div field="name" width="120" headerAlign="center" allowSort="true">名称</div>
					<div field="no" width="140" headerAlign="center" allowSort="true">设备S/N</div>
					<div field="types" width="80" headerAlign="center" allowSort="true" align="center">类型</div>
					<div field="brand" width="80" headerAlign="center">品牌</div>
					<div field="count" width="40" headerAlign="center" align="center">数量</div>
					<div field="remark" width="350" headerAlign="center">备注</div>
				</div>
			</div>
		</td>
	</tr>
</table>
<script type="text/javascript">
mini.parse();
var grid = mini.get("grid1");
grid.load();
var grid2 = mini.get("grid2");

//设置行样式
grid.on("drawcell", function (e) {
	var bgcolor=["","mediumspringgreen","limegreen","lightgreen","darkcyan","olivedrab","orange","peru","tomato","orangered","red"];
	e.cellStyle = "background:" + bgcolor[e.record.statuss];
});

//设置行样式
grid2.on("drawcell", function (e) {
	if(e.record.types=="领取"){
		e.cellStyle = "background:limegreen;";
	}else{
		e.cellStyle = "background:orangered;";
	}
});

//查询
$("#search").click(function(){
	grid.load({
			id:mini.get("order_no").getValue(),
			order_id:mini.get("order_id").getValue(),
			types:mini.get("types").getValue(),
			con_agency_id:mini.get("conagency").getValue()
		});
});

//选择
function onSelectionChanged(e) {
	var gridSelection = e.sender;
	var record = gridSelection.getSelected();
	if (record) {
		grid2.load({cid:record.id});
	}
}

//领取设备
function BusinessGet(){
	var row = grid.getSelected();
	if (row != null) {
		mini.open({
            url: "/business/businessGet",
            title: "领取派工设备", width: 530, height:280,
            onload: function()
            {
                var iframe = this.getIFrameEl();
                var data = { action: "edit",id:row.id,types:"领取"};
                iframe.contentWindow.SetData(data);
            },
            ondestroy:function(action)
            {
            	grid.load({
            		id:mini.get("order_no").getValue(),
        			order_id:mini.get("order_id").getValue(),
        			types:mini.get("types").getValue(),
        			con_agency_id:mini.get("conagency").getValue()
                });
            }
        });
		$(".mini-panel-border .mini-panel-body iframe").css("height","95%");
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
}

//归还设备
function BusinessSet(){
	var row = grid.getSelected();
	if (row != null) {
		mini.open({
            url: "/business/businessSet",
            title: "归还剩余设备", width: 530, height:280,
            onload: function()
            {
                var iframe = this.getIFrameEl();
                var data = { action: "edit",id:row.id,types:"归还"};
                iframe.contentWindow.SetData(data);
            },
            ondestroy:function(action)
            {
            	grid.load({
            		id:mini.get("order_no").getValue(),
        			order_id:mini.get("order_id").getValue(),
        			types:mini.get("types").getValue(),
        			con_agency_id:mini.get("conagency").getValue()
                });
            }
        });
		$(".mini-panel-border .mini-panel-body iframe").css("height","95%");
	} else {
		parent.$.dooDialog.alert("请选中一条记录");
	}
}
</script>